//
//  MKTRegisterManager.h
//  MKUITestApp
//  注册管理器,一般用于注册事件类型与对应的响应处理器
//  Created by 苏尚进 on 2021/7/9.
//  Copyright © 2021 moon. All rights reserved.
//

#import <Foundation/Foundation.h>

#define kMKTRegisterPriotiryDefault 0
#define kMKTRegisterPriotiryLow 10
#define kMKTRegisterPriotiryNormal 100
#define kMKTRegisterPriotiryHigh 1000


NS_ASSUME_NONNULL_BEGIN
//注册表里的某一个选项
@interface MKTRegisterOption : NSObject
@property(nonatomic,strong) id key;//key值,用于被索引
@property(nonatomic,strong) id value;//key对应的实体
@property(nonatomic,assign) NSInteger priority;//优先级,值越高,优先级越高
@property(nonatomic,strong,nullable) id userInfo;
- (id)initWithKey:(id)key value:(id)value priority:(NSInteger)priority;
@end
NS_ASSUME_NONNULL_END

NS_ASSUME_NONNULL_BEGIN

@interface MKTRegisterManager : NSObject
+ (nonnull instancetype)sharedInstance;
/**
 *  进行注册,默认的类别是@""
 *
 *  @param option 被注册的对象
 */
- (void)registerOption:(MKTRegisterOption *)option;

/**
 *  进行注册
 *
 *  @param option   被注册的对象
 *  @param category 要归到的类别
 */
- (void)registerOption:(MKTRegisterOption *)option forCategory:(nullable NSString *)category;

/**
 *  取消注册,默认的类别是@""
 *
 *  @param option 被注册的对象
 */
- (void)unregisterOption:(MKTRegisterOption *)option;
/**
 *  取消注册
 *
 *  @param option   被注册的对象
 *  @param category 要移除的类别
 */
- (void)unregisterOption:(MKTRegisterOption *)option forCategory:(nullable NSString *)category;
- (void)unregisterOptionsForKey:(id)key;
- (void)unregisterOptionsForKey:(id)key forCategory:(nullable NSString *)category;

/**
 *  根据key索引值,获取优先级最高的注册对象
 *
 *  @param key 索引值
 *
 *  @return 注册的处理对象
 */
- (nullable id)valueRegistedForKey:(id)key;

/**
 *  根据key索引值,在指定的类别下,获取优先级最高的注册对象
 *
 *  @param key      索引值
 *  @param category 类型
 *
 *  @return 注册的处理对象
 */
- (nullable id)valueRegistedForKey:(id)key category:(nullable NSString *)category;

- (nullable MKTRegisterOption *)optionRegistedForKey:(id)key;

- (nullable MKTRegisterOption *)optionRegistedForKey:(id)key category:(nullable NSString *)category;

/**
 *  返回指定类别下的注册对象列表
 *
 *  @param category 类型
 *
 *  @return @{key:@[MKTRegisterOption]}
 */
- (nullable NSDictionary *)optionsRegistedForCategory:(nullable NSString *)category;

@end

NS_ASSUME_NONNULL_END
